package com.android;

import java.util.ArrayList;



import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.view.View.OnClickListener;

public class HightScore extends Activity{
	TableLayout dataTable;
	//private int cAstar,times;
	DataBaseManager db;
	@Override
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.score);
        db = new DataBaseManager(this);
       // TextView textFieldOne,textFieldTwo,idField;
        //updateTable();
        Button backB = (Button) findViewById(R.id.back);
        dataTable = (TableLayout) this.findViewById(R.id.data_table);
        updateTable();
        //textFieldOne = 		(TextView)findViewById(R.id.txtid);
        //textFieldTwo = 		(TextView)findViewById(R.id.txttime);
        //idField = 			(TextView)findViewById(R.id.txtmove);
        backB.setOnClickListener(new OnClickListener() {
            
        	public void onClick(View v) {
            	finish();
            }
        });
	}
	//protected void setValueAstar( int num){
        //this.cAstar = num;
	//}
    
	void updateTable(){
    	while (dataTable.getChildCount() > 1){
    		dataTable.removeViewAt(1);
    	}
    	//db.getRowAsArray();
    	ArrayList<ArrayList<Object>> data = db.getAllRowsAsArrays();
    	//int size = data.size();
    	//int array_time[] = new int [size];
    	
    	for (int i=0; i < data.size(); i++){
    		TableRow tableRow= new TableRow(this);
    		if(i<=9){
    			ArrayList<Object> row = data.get(i);
        		String id = row.get(0).toString();
        		String time = row.get(1).toString();
        		String move = row.get(2).toString();

        		TextView idText = new TextView(this);
        		
            		idText.setTextSize(25);
            		idText.setText("  "+(i+1));
            		tableRow.addView(idText);
         
            		TextView textOne = new TextView(this);
            		 textOne.setTextSize(25);
            		textOne.setText("       "+time);
            		tableRow.addView(textOne);
         
            		TextView textTwo = new TextView(this);
            		textTwo.setTextSize(25);
            		textTwo.setText("       "+move);
            		tableRow.addView(textTwo);
            		dataTable.addView(tableRow);
    		 }else{
    		
    		}
    		
    	}
    	
    }
}
